﻿// (c) Copyright 2013 Mike Riedel.
// This source is subject to the Microsoft Public License (Ms-PL).
// All other rights reserved.

namespace FreshMeat.Storage
{
   /// <summary>
   /// Performs mapping betweeen an item and its storage representation.
   /// </summary>
   /// <typeparam name="TId"></typeparam>
   /// <typeparam name="TItem"></typeparam>
   /// <typeparam name="TData"></typeparam>
   public interface IMapper<out TId, TItem, TData>
   {
      /// <summary>
      /// Maps item onto its data representation.
      /// </summary>
      /// <param name="item">Item to map.</param>
      /// <returns>Data representation.</returns>
      TData ToData(TItem item);

      /// <summary>
      /// Maps data representation back onto item.
      /// </summary>
      /// <param name="data"></param>
      /// <returns></returns>
      TItem ToItem(TData data);

      /// <summary>
      /// Gets an item's ID.
      /// </summary>
      /// <param name="item"></param>
      /// <returns></returns>
      TId ToId(TItem item);
   }
}